package com.xiaoying.server.publish.utils;

import java.util.Date;
import java.util.Random;

import org.junit.Test;

public class RandomUtil {
	
	public static long SEEDTIME=0L;
	public static double MULTI=10000000000.0;
	public static double MULTI2=2000;
	
	
	public static String get3FileName(){
		Random random = new Random(getLongSeed());
		String randomString ="";
        for(int i=0; i<3;i++){
            int choice = random.nextInt(2) % 2 == 0 ? 65 : 97; // 取得大写还是小写
            char ch = (char)(choice + random.nextInt(26));
            randomString += ch;
        }
		return randomString;		
	}
	
	/**
	 * 获取线程睡眠时间
	 * @param date
	 * @return
	 */
	public static long getRandomSleepTime(){
		Double tmp = Math.random()*MULTI2;
		return tmp.longValue();
	}
	
	/**
	 * 获取随机0-N的随机种子
	 * @param date
	 * @param N
	 * @return
	 */
	public static int getRandomSeedUnderN(int N){
		Random random = new Random(getLongSeed());
		return random.nextInt(N);
	}
	
	/**
	 * 获取随机种子
	 * @return
	 */
	public static long getLongSeed(){
		Double tmp = Math.random()*MULTI;
		return tmp.longValue();
	}
	
	
	@Test
	public void testit(){
		for(int i=0;i<100;i++){		
			Double tmp = Math.random()*MULTI2;
			System.out.println(tmp.longValue());	
		}

	}
	
	

}
